// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import "Variable.js" as Variable
Dialog {
   id: myDialog
//   property string pass: Qt.md5("Hello World")
   property string msg: "Identification"
   title: Item{
        id: item_title
        height: label_login.height + titleField.height + 20
        width: parent.width
        Text{
            id: label_login
//            text: qsTr("Identification")
            text: msg
            color: "white"
            font.pixelSize: 30
            onTextChanged: console.debug("[Login] Text changed : " + text)
        }
        Rectangle {
            id: titleField
            height: 2
            width: parent.width
            anchors.top: label_login.bottom
            color: "blue"
        }
    }

   content: Item {
       id: item_content
       width: parent.width
       height: line_user.height + line_pass.height + 20
       TextField{
           id: line_user
           placeholderText: "Utilisateur"
           width: parent.width
       }
       TextField{
           id: line_pass
           placeholderText: "Mots de passe"
           width: parent.width
           anchors.top: line_user.bottom
           anchors.topMargin: 10
           echoMode: TextInput.Password

       }

   }

   buttons: Item {
       height: btn_cancel.height + btn_ok.height + 20
       Button {
           id: btn_ok;
           text: "OK";
           checked: true
           onClicked: {
               if( line_user.text == "")
               {
                   console.debug("Pas d'utilisateur")
               }
               else if(line_pass.text == "")
               {
                   console.debug("Pas de mots de passe")
               }
               else
               {
                   Variable.setLogin(line_user.text,Qt.md5(line_pass.text));
                   myDialog.accept()
               }

           }
       }
       Button {
           id: btn_cancel;
           text: "Annuler";
           anchors.top: btn_ok.bottom
           anchors.topMargin: 10
           onClicked: myDialog.close()
       }
     }
   }
